package com.jindy.module.serialNum.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.serialNum.domain.SySerialNumT;
import com.jindy.module.serialNum.service.ISySerialNumTService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 单流水生成Controller
 * 
 * @author jindy
 * @date 2023-04-16
 */
@RestController
@RequestMapping("/module/serialNum")
public class SySerialNumTController extends BaseController
{
    @Autowired
    private ISySerialNumTService sySerialNumTService;

    /**
     * 查询单流水生成列表
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:list')")
    @GetMapping("/list")
    public TableDataInfo list(SySerialNumT sySerialNumT)
    {
        startPage();
        List<SySerialNumT> list = sySerialNumTService.selectSySerialNumTList(sySerialNumT);
        return getDataTable(list);
    }

    /**
     * 导出单流水生成列表
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:export')")
    @Log(title = "单流水生成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SySerialNumT sySerialNumT)
    {
        List<SySerialNumT> list = sySerialNumTService.selectSySerialNumTList(sySerialNumT);
        ExcelUtil<SySerialNumT> util = new ExcelUtil<SySerialNumT>(SySerialNumT.class);
        util.exportExcel(response, list, "单流水生成数据");
    }

    /**
     * 获取单流水生成详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sySerialNumTService.selectSySerialNumTById(id));
    }

    /**
     * 新增单流水生成
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:add')")
    @Log(title = "单流水生成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SySerialNumT sySerialNumT)
    {
        return toAjax(sySerialNumTService.insertSySerialNumT(sySerialNumT));
    }

    /**
     * 修改单流水生成
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:edit')")
    @Log(title = "单流水生成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SySerialNumT sySerialNumT)
    {
        return toAjax(sySerialNumTService.updateSySerialNumT(sySerialNumT));
    }

    /**
     * 删除单流水生成
     */
    @PreAuthorize("@ss.hasPermi('module:serialNum:remove')")
    @Log(title = "单流水生成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sySerialNumTService.deleteSySerialNumTByIds(ids));
    }
}
